package com.lizba.redis.limit.slidinwindow;

import redis.clients.jedis.Jedis;

import java.util.concurrent.TimeUnit;

/**
 * <p>
 *
 * </p>
 *
 * @Author: Liziba
 * @Date: 2021/9/6 20:10
 */
public class TestSimpleSlidingWindowByZSet {

    public static void main(String[] args) throws InterruptedException {
        Jedis jedis = new Jedis("192.168.211.108", 6379);
        SimpleSlidingWindowByZSet slidingWindow = new SimpleSlidingWindowByZSet(jedis);
        for (int i = 1; i <= 15; i++) {
            TimeUnit.MILLISECONDS.sleep(1);
            boolean actionAllowed = slidingWindow.isActionAllowed("liziba", "view", 60, 5);
            System.out.println("第" + i +"次操作" + (actionAllowed ? "成功" : "失败"));
        }


        jedis.close();
    }

}
